Skip to main content

弹出框 panel

sbulime 的下方弹出框

基于 panel 的弹出框是sublime内置的api,没有暴露太多接口,首先看看一个弹出框有哪些配置

创建一个panel

# 获取 window 对象
window = sublime.active_window()

# 创建一个 panel
panel = window.create_output_panel('testt')

# 查看默认配置
settings = panel.settings()
for key, value in OUTPUT_PANEL_SETTINGS.items():
# settings.set(key, value)
print(f'"{key}":{value}')


# 验证刚才创建的pannel是否成功,
# f"名字是 output.{name}"
window.find_output_panel('output.testt') # True
# or
'output.testt' in window.panels() # True

查看当前显示的 panel

currt_panel = window.active_panel()

if currt_panel == f"output.{name}": # True/False

默认配置

# DEFAULT_PANEL_SETTINGS
{
"auto_indent": False, # 是否自动缩进
"draw_indent_guides": False, #
"draw_unicode_white_space": None, #
"draw_white_space": None, #
"fold_buttons": True, #
"gutter": True, #
"is_widget": True, #
"line_numbers": False, #
"lsp_active": True, #
"margin": 3, #
"match_brackets": False, #
"rulers": [], #
"scroll_past_end": False, #
"show_definitions": False, #
"tab_size": 4, #
"translate_tabs_to_spaces": False,#
"word_wrap": False, #
}

显示一个panel

sublime.run_command('show_panel', {})

更新panel的内容

panel_run_command(command:str, argv:dict)

参考方案1

  • lsp的panel.py